package com.butterfly.hotkey.common.exception;

/**
 * 公共的异常
 *
 * @author butterfly
 */
public class CommonException extends RuntimeException implements IException {

    protected Integer code;

    protected String errorMessage;

    public CommonException(IException exceptionCode) {
        super(exceptionCode.getMessage());
        this.errorMessage = exceptionCode.getMessage();
        this.code = exceptionCode.getCode();
    }

    public CommonException(IException exceptionCode, Object... args) {
        super(String.format(exceptionCode.getMessage(), args));
        this.errorMessage = exceptionCode.getMessage();
        this.code = exceptionCode.getCode();
    }


    @Override
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
}
